package com.guit.hrms.mapper;

import com.guit.hrms.po.dept.GetDeptPerson;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface EmployeeMapper {


    /**
     * 删除的员工修改
     * @param deptId
     */
    @Update("update employees set department = 0 ,position = 0 where department = #{deptId}")
    void setDeptAndPositionByDeptId(Integer deptId);

    /**
     * 获取部门人员
     * @param deptId
     * @param deptType
     * @param positionId
     * @return
     */
    @Select("select e.employee_id ,e.username name,o.onboarding_time from employees e ,onboarding o where e.interviewee_id = o.interviewee_id and e.department = #{deptId} and e.dept_type = #{deptType} and e.position = #{positionId} and (e.status = 1 or e.status = 0) ")
    List<GetDeptPerson> getDeptPerson(Integer deptId, Integer deptType, Integer positionId);

    /**
     * 根据员工id查找roleId
     * @param employeeId
     * @return
     */
    @Select("select role_id from employee_roles where employee_id = #{employeeId}")
    Integer getRoleIdByEmployeeId(String employeeId);
}

